package com.smbms.service.impl;

import com.smbms.dao.UserMapper;
import com.smbms.entity.User;
import com.smbms.service.UserService;
import com.smbms.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getList(User user) {
        return userMapper.getListAll(user);
    }


    @Override
    public User login(String userCode, String userPassword) {
        return userMapper.login(userCode,userPassword);
    }

    @Override
    public User getId(Integer id) {
        return userMapper.getId(id);
    }

    @Override
    public Result save(User user) {
        int count=this.userMapper.save(user);
        if(count==1) {
            return Result.reOk("新增成功");
        }else{
            return Result.reOk("新增失败");
        }
    }

    @Override
    public Result update(User user) {
        int count=this.userMapper.updateUser(user);
        if(count==1) {
            return Result.reOk("修改成功");
        }else{
            return Result.reOk("修改失败");
        }
    }


}
